<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateYUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('y_users')) {
            Schema::create('y_users', function (Blueprint $table) {
                $table->engine = 'MyISAM';
                $table->increments('user_id');
                $table->string('user_thumbnail')->default('')->comment('微信头像');
                $table->string('user_name', 30)->default('')->comment('用户名');
                $table->string('user_open_id', 50)->default('')->comment('微信open_id');
                $table->string('user_nickname', 50)->default('')->comment('微信昵称');
                $table->boolean('user_sex')->default(0)->comment('性别1男，2女');
                $table->string('user_password')->default('')->comment('密码');
                $table->string('user_wechat_id', 20)->default('')->comment('微信号');
                $table->string('user_mobile_phone', 20)->default('')->comment('手机号');
                $table->string('user_province', 20)->default('')->comment('省');
                $table->string('user_city', 20)->default('')->comment('城市');
                $table->integer('user_money')->default(0)->comment('金币');
                $table->boolean('user_allow_chat')->default(0)->comment('0不允许私信，1允许');
                $table->integer('user_rank_number')->default(0)->comment('等级');
                $table->integer('user_all_ticket')->default(0)->comment('总表');
                $table->integer('user_ticket')->default(0)->comment('可用票');
                $table->smallInteger('user_uprank_type')->default(1)->comment('下一等级升级类型');
                $table->integer('user_uprank_ticket')->default(0)->comment('升级所需票数');
                $table->integer('user_used_ticket')->default(0)->comment('此等级下已用票');
                $table->boolean('user_status')->default(1)->comment('0封号，1解封');
                $table->boolean('user_type')->default(0)->comment('0系统号，1用户');
//                $table->rememberToken();
                $table->timestamps();

                //索引
                $table->index('user_open_id');
                $table->index('user_mobile_phone');
                $table->index('user_province');
                $table->index('user_sex');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('y_users');
    }
}
